//****************************************************************
//* Copyright (c) 2004 Ford Motor Company. All Rights Reserved.
//*
//* $$Workfile:   UsageFindQuery.java  $$
//* $$Revision:   1.0  $$
//* $$Author:   aponte  $$
//* $$Date:   Dec 10 2008 11:00:04  $$
//*
//*****************************************************************
package ar.com.ford.it.fullEconomics.persistence.dao.query;

import java.sql.Timestamp;
import oracle.toplink.expressions.Expression;
import oracle.toplink.expressions.ExpressionBuilder;
import ar.com.ford.it.fullEconomics.persistence.dto.Ncas104SfiVw;
import ar.com.ford.it.fullEconomics.persistence.dto.Teesg01Plant;
import com.ford.it.persistence.impl.toplink.CustomExpressionFactory;

public class UsageFindQuery implements CustomExpressionFactory {

	public Expression createExpression(ExpressionBuilder builder,
			Object[] parameters) {
		Expression exp = null;
		Timestamp fechaInicio = (Timestamp) parameters[0];
		Timestamp fechaFin = (Timestamp) parameters[1];
		Teesg01Plant teesg01Plant = (Teesg01Plant) parameters[2];
		Ncas104SfiVw ncas104SfiVw = (Ncas104SfiVw) parameters[3];

		exp = builder.get("eesp07PlantCodeC").equal(teesg01Plant);
		exp = exp.and(builder.get("ncas104SfiVw").equal(ncas104SfiVw));

		// Comparo la vigencia del uso
		exp = exp.and(builder.get("eesp07UsageInDateY").lessThan(fechaInicio));
		exp = exp.and(builder.get("eesp07UsageOutDateY").greaterThan(fechaFin));
		
/*
 *** LSPARACI ***
		// Comparo la vigencia de la parte
		exp = exp.and(builder.get("teesp01Part").get("eesp01PartInDateY")
				.lessThan(fechaInicio));
		exp = exp.and(builder.get("teesp01Part").get("eesp01PartOutDateY")
				.greaterThan(fechaFin));
*/
		return exp;
	}

}
